﻿using System;
using System.Collections.Generic;

using System.Text;
using System.Data;
using ModuleDALCore;
using QUANLYCHAMCONG.DAO.Core;
using QUANLYCHAMCONG.BL.Entities;

namespace QUANLYCHAMCONG.DAO.DAO
{
    public class TANGCADAO:DALBase
    {
        TANGCA tc;
         private string _SpName;
        public string SpName
        {
            get { return "SpTANGCA"; }
            set { _SpName = value; }
        }
        public TANGCADAO()
        {
            OpenConnect();
        }
        public bool Insert(TANGCA tc)
        {
            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(tc, null), ConvertClassToArray.GetValues(tc,1)) == 1);
            }
            catch
            {
                return false;
            }
        }
        public bool Update(TANGCA tc)
        {
            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(tc, null), ConvertClassToArray.GetValues(tc,2)) == 1);
            }
            catch
            {
                return false;
            }
        }
        public bool Delete(TANGCA tc)
        {
            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(tc, null), ConvertClassToArray.GetValues(tc,3)) == 1);
            }
            catch
            {
                return false;
            }
        }
        public DataTable SelectByPK(TANGCA tc)
        {
            try
            {
                return DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(tc, null), ConvertClassToArray.GetValues(tc,4));
            }
            catch
            {
                return null;
            }
        }
        public DataTable SelectALL()
        {
            tc = new TANGCA();
            try
            {
                return DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(tc, null), ConvertClassToArray.GetValues(tc,0));
            }
            catch
            {
                return null;
            }
        }
        public int GetID()
        {
            tc = new TANGCA();
            try
            {
                return DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(tc, null), ConvertClassToArray.GetValues(tc, 5), DBConnectionState.CloseOnExit);
            }
            catch
            {
                return 0;
            }
        }
        public DataTable SelectALLDiTre()
        {
            tc = new TANGCA();
            try
            {
                return DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(tc, null), ConvertClassToArray.GetValues(tc, 6));
            }
            catch
            {
                return null;
            }
        }
        public DataTable SelectALLVeSom()
        {
            tc = new TANGCA();
            try
            {
                return DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(tc, null), ConvertClassToArray.GetValues(tc, 7));
            }
            catch
            {
                return null;
            }
        }
        public DataTable CheckExits(TANGCA tc)
        {
            try
            {
                return DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(tc, null), ConvertClassToArray.GetValues(tc, 8));
            }
            catch
            {
                return null;
            }
        }
        public DataTable SelectALLPhepNam()
        {
            tc = new TANGCA();
            try
            {
                return DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(tc, null), ConvertClassToArray.GetValues(tc, 9));
            }
            catch
            {
                return null;
            }
        }
        public DataTable SelectALLDiCongTac()
        {
            tc = new TANGCA();
            try
            {
                return DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(tc, null), ConvertClassToArray.GetValues(tc, 10));
            }
            catch
            {
                return null;
            }
        }
    }
}
